package com.jeesite.modules.commands.entity;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Size;
import jakarta.validation.constraints.NotNull;

import com.jeesite.common.entity.DataEntity;
import com.jeesite.common.mybatis.annotation.Column;
import com.jeesite.common.mybatis.annotation.Table;
import com.jeesite.common.mybatis.mapper.query.QueryType;

import java.io.Serial;

/**
 * 指令表，记录指令Entity
 * @author LaVenderGong
 * @version 2025-08-20
 */
@Table(name="commands", alias="a", label="指令表，记录指令信息", columns={
		@Column(name="id", attrName="tid", label="id", isPK=true),
		@Column(name="command_string", attrName="commandString", label="命令字符串"),
		@Column(name="description", attrName="description", label="指令描述", queryType=QueryType.LIKE),
		@Column(name="permission", attrName="permission", label="允许执行的权限"),
		@Column(name="name", attrName="name", label="指令名字", queryType=QueryType.LIKE),
		@Column(name="grammer", attrName="grammer", label="语法"),
		@Column(name="example", attrName="example", label="使用例子"),
	}, orderBy="a.id DESC"
)
public class Commands extends DataEntity<Commands> {
	
	@Serial
	private static final long serialVersionUID = 1L;
	private Long tid;		// id
	private String commandString;		// 命令字符串
	private String description;		// 指令描述
	private Long permission;		// 允许执行的权限
	private String name;		// 指令名字
	private String grammer;		// 语法
	private String example;		// 使用例子

	public Commands() {
		this(null);
	}
	
	public Commands(String id){
		super(id);
	}
	
	@JsonSerialize(using = ToStringSerializer.class)
	public Long getTid() {
		return tid;
	}

	public void setTid(Long tid) {
		this.tid = tid;
	}
	
	@NotBlank(message="命令字符串不能为空")
	@Size(min=0, max=500, message="命令字符串长度不能超过 500 个字符")
	public String getCommandString() {
		return commandString;
	}

	public void setCommandString(String commandString) {
		this.commandString = commandString;
	}
	
	@Size(min=0, max=500, message="指令描述长度不能超过 500 个字符")
	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}
	
	@NotNull(message="允许执行的权限不能为空")
	public Long getPermission() {
		return permission;
	}

	public void setPermission(Long permission) {
		this.permission = permission;
	}
	
	@Size(min=0, max=50, message="指令名字长度不能超过 50 个字符")
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
	
	@Size(min=0, max=500, message="语法长度不能超过 500 个字符")
	public String getGrammer() {
		return grammer;
	}

	public void setGrammer(String grammer) {
		this.grammer = grammer;
	}
	
	@Size(min=0, max=500, message="使用例子长度不能超过 500 个字符")
	public String getExample() {
		return example;
	}

	public void setExample(String example) {
		this.example = example;
	}
	
}